1. Field of the Invention
The present invention relates to a flash memory rewriting circuit to rewrite data of a flash memory embedded in a microcontroller (hereinafter referred to as a xe2x80x9cmiconxe2x80x9d).
2. Description of the Related Art
A micon is built in an electric product of a certain kind to control its operation. A manufacturer of electric products who manufactures and sells such electric products in which the micon is built in purchases the micon to be built in electric products from semiconductor manufacturers.
The micon is provided with a central processing unit (hereinafter referred to as a xe2x80x9cCPUxe2x80x9d) and a memory in which an operating program defining operations of the CPU is stored. As a memory of such micons to be built in electric products, generally, a flash ROM is used, so that an electric product manufacturer being a user of the micon can write their own original programs suitable for each electric product in which the micon is built on the memory of the micon or can amend and/or change operating programs written on the memory.
To rewrite the operating program stored in the flash ROM, a method is conventionally available in which the micon itself is operated and rewriting of the flash ROM is controlled. Since this method allows the use of serial I/O devices mounted on peripheral circuits (hereafter referred to as a xe2x80x9cperipheralxe2x80x9d), a RAM (Random Access Memory) and the like, the number of terminals for interface with external devices can be small and, even after the implementation of the micon on a system board of electric products, the rewriting of the flash ROM is made possible. However, this method presents a problem in that, when the flash ROM is rewritten by the operation of the micon, if a rewriting program is simply stored in the flash ROM, while the rewriting of the operating program of the flash ROM is executed in accordance with the rewriting program, the CPU of the micon cannot read data from the flash memory and therefore the omission of input data to the CPU occurs, thus causing a run-away of the CPU. To solve this problem, a mask ROM and/or a RAM to be exclusively used to store a rewriting program are used conventionally as a flash memory rewriting circuit as shown in FIGS. 2 and 3.
FIG. 2 is a block diagram showing one example of a conventional flash memory rewriting circuit. FIG. 3 is a block diagram showing another example of a conventional flash memory rewriting circuit.
In general, the micon has a CPU 1, a RAM (not shown), peripherals 2 including serial I/O devices and the like constituting an input/output section used to serially input and output data, which is inputted or outputted to and from the CPU, to and from external devices, and a flash memory 3.
As shown in FIG. 2, in addition to these components described above, a mask ROM 4 is mounted on the micon to constitute a flash memory rewriting circuit. As depicted in FIG. 3, in addition to these components described above, a RAM 5 and a download circuit 6 are mounted on the micon. A rewriting program is stored in the mask ROM 4. Data stored in the mask ROM 4 and data stored in the flash. ROM 3 are selected by a selector 7 and read by the CPU 1. The RAM 5 shown in FIG. 3 stores the rewriting program fed through the download circuit 6. Data stored in the RAM 5 and data stored in the flash ROM 3 are selected also by a selector 7 and read by the CPU 1.
However, such conventional flash memory rewriting circuits as shown in FIGS. 2 and 3 present the following problems. That is, if such a mask ROM 4 as shown in FIG. 2 is used as a flash memory rewriting circuit, since the rewriting program is stored in the mask ROM 4, a method for transferring the rewriting data in accordance with the program is fixed. Therefore, to change the content stored in the mask ROM 4, it is necessary to rebuild the micon and to change the rewriting program stored in the mask ROM 4. Moreover, since the rewriting program stored in the mask ROM is fixed in accordance with each electrical product, a third party can easily read or rewrite the data stored in the flash ROM 3, presenting a problem from the viewpoint of security of the program. That is, contents of the rewriting program containing the data transfer program stored in the mask ROM 4 have been publicized so that each user can write an original operating program in accordance with characteristics of electric products into which the program is installed. Because of this, detailed contents of the rewriting program can be known from the publicized information and, as a result, an originally designed operating program stored in the flash ROM can be comparatively easily read by a third party.
On the other hand, if such a RAM 5 as shown in FIG. 3 is used, both the download circuit 6 to download the rewriting program and an interface circuit to transfer the rewriting data to the flash ROM 3 have to be mounted on the system of users. When the rewriting program is downloaded to this RAM 5, since a third party also can easily create the rewriting program, reading or rewriting of data stored in the flash ROM can be also made easy, presenting a problem from the viewpoint of security of programs. That is, detailed procedures for downloading to the download circuit 6 have been publicized so that each user can write an original operating program in accordance with characteristics of electric products into which the program is installed. Because of this, by knowing the publicized procedure, the rewriting program itself stored in the RAM 5 can be easily written and, as a result, the operating program stored in the flash ROM can be also comparatively easily read out by a third party.
In view of the above, it is an object of the present invention to provide a flash memory rewriting circuit which does not cause a reduction in maintaining the security of an operating program. It is another object of the present invention to provide a flash memory rewriting circuit wherein there is no need for newly mounting a purpose-built RAM or a ROM for rewriting of the flash memory.
According to a first aspect of the present invention, there is provided a flash memory rewriting circuit being integrated into a microcontroller having a CPU, a flash memory in which an operating program defining an operation of said CPU is stored and an input/output section to input and output data from and to external devices in order to rewrite, by operations of the CPU, the operating program stored in the flash memory, comprising:
a transfer program storing region provided, within the flash memory, in a memory region other than an operating program storing region in which the operating program is stored, which also stores a data transfer program to transfer a data for rewriting the operating program to the flash memory through the external devices when the data transfer program is read and executed by the CPU; and
a read only memory storing a rewriting execution program to have rewriting data fed by external devices written on the operating program storing region of the flash memory when the rewriting execution program is read and executed by the CPU.
In the foregoing, a preferable mode is one wherein the data transfer program contains a portion of a program to instruct the CPU to read the rewriting execution program stored in the read only memory.
Also, a preferable mode is one wherein the data transfer program is directly written on the data transfer program storing region of the flash memory without the use of the CPU.
Also, a preferable mode is one wherein the micon is mounted on a system board fitted to electrical products for controlling operations of the same and the writing of the data transfer program is carried out prior to the implementation of the micon to the system board.
Also, a preferable mode is one wherein the writing of the data transfer program on the data transfer program region is performed by users who purchase the micon and build it into the electric products.
Also, a preferable mode is one wherein the micon is provided with a selector used to cause the CPU to selectively access the read only memory and the flash memory.
Also, a preferable mode is one wherein the flash memory rewriting circuit is provided with a rewrite inhibiting circuit used to inhibit the rewriting of the data transfer program caused by run-away of the CPU.
Also, a preferable mode is one wherein the rewrite inhibiting circuit inhibits the transfer of data having an address designating the transfer program storing region of the flash memory to the flash memory.
Furthermore, a preferable mode is one wherein the rewrite inhibiting circuit is disposed between the CPU and the flash memory.
According to a second aspect of the present invention, there is provided a flash memory rewriting circuit being integrated into a micon having a CPU, a flash memory in which an operating program defining an operation of the CPU is stored and an input/output section to input and output data to and from external devices in order to rewrite, by operations of the CPU, the operating program stored in the flash memory, comprising:
a rewriting program storing region provided, within the flash memory, in a memory region other than an operating program storing region in which the operating program is stored, which also stores a rewriting program to read rewriting data for rewriting of the operating program from external devices through the input/output section when the rewriting program is read and executed by the CPU; and
a write controlling circuit disposed between the CPU and the flash memory to be operated in synchronization with clocks of the CPU, which receives (more than one) rewriting signals used to rewrite the operating program on the operating program storing region of the flash memory by the execution of the rewriting program through the use of the CPU and which rewrites the rewriting data on the operating program storing region after receiving a rewriting execution signal from the CPU and, during the execution of the rewriting, sends out a standby requesting signal to the CPU to prevent run-away of the CPU.
In the foregoing, it is preferable that the rewriting program is directly written on the rewriting program storing region of the flash memory without the use of the CPU.
Also, it is preferable that the micon is mounted on a system board fitted to electrical products for controlling operations of the same and the writing of the rewriting program is carried out prior to the implementation of the micon to said system board.
Also, it is preferable that the writing of the rewriting program on the rewriting program storing region is performed by users who purchase the micon and build it into the electric products.
Furthermore, it is preferable that the write controlling circuit is comprised of a register to read the rewriting data through the execution of the rewriting program by the CPU, a register to read a specified address for the rewriting data and a standby signal generating circuit to return the standby requesting signal to cause the access of the CPU to the flash memory to wait when receiving the rewriting execution signal from the CPU.